/*
 * 角色管理
 */

Ext.onReady(function(){
	Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';//处理ie提交中文乱码问题
    var fm = Ext.form;
	var sm = new Ext.grid.CheckboxSelectionModel({handleMouseDown: Ext.emptyFn});
    var cm = new Ext.grid.ColumnModel([
		sm,{
			header:'编号',
			dataIndex:'id',
			width:40
		},{
			header: "角色名称",
			dataIndex: 'name',
			editor: new fm.TextField({
				allowBlank: false
			})
        },{
			header:'名称',
			dataIndex:'memo',
			width:120,		
			editor: new fm.TextField({
				allowBlank: false
			})
		}
    ]);
    cm.defaultSortable = true;

    var SaleArea = Ext.data.Record.create([
           {name: 'id', type: 'int'},
           {name: 'name', type: 'string'},
		   {name: 'memo'}
      ]);

	var store = new Ext.data.JsonStore({
		url:'../'+WebServiceUrl,
		baseParams:{trancode:'1020'},
		totalProperty:'totalProperty',
		root:'root',
		fields:SaleArea,
		pruneModifiedRecords:true
		//sortInfo: {field: "regionId", direction: "ASC"} //设置默认排序规则, EditorGridPanel在新增加一行却未保存时如果点击header排序会出现'行142字符6983,modified为空或不是对象'
	});

	//表单窗体
	var memberAddWindow;

    var grid = new Ext.grid.EditorGridPanel({
    	id : 'BaseGrid',
        store: store,
        cm: cm,
        renderTo: 'role_grid',
        resizeable:true,
        height:494,
        width:807,
        title:'角色管理',
        frame:true,
        clicksToEdit:1,
		sm:sm,
		iconCls:'icon-grid',
		loadMask: {msg:'正在加载数据，请稍候。。。'},
		stripeRows:true,
		tbar:[
		{
			id:'newWindowButton',
			text:'选择',
			iconCls:'add',
			handler:function(){
			    var w = new SelGrid();
			    w.show();
			}
		},
		{
			id:'newWindowButton',
			text:'选择',
			iconCls:'add',
			handler:function(){
			   new App.CheckBoxGrid(grid);	
			}
		}],
	    bbar: new Ext.PagingToolbar({
	        pageSize: App.pageSize,
	        store: store,
	        displayInfo: true,
	        displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	        emptyMsg: "没有记录"
	    })

    });
    store.load({params:{start:0,limit:App.pageSize}});	
});
